package org.dashboard.service.impl;


import com.alibaba.dubbo.config.annotation.Service;
import org.dashboard.bean.AdAuthorization;
import org.dashboard.constant.Constant;
import org.dashboard.dao.AdAuthorizationMapper;
import org.dashboard.service.AdAuthorizationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;

import java.util.List;

@Service(interfaceClass = AdAuthorizationService.class)
@CacheConfig(cacheManager = Constant.DEFAULT_CACHE_MANAGER)
public class AdAuthorizationServiceImpl implements AdAuthorizationService {

    private static final Logger logger = LoggerFactory.getLogger(AdAuthorizationServiceImpl.class);

    @Autowired
    AdAuthorizationMapper adAuthorizationMapper;

    @Override
    public int deleteByPrimaryKey(Integer authorizationId) {
        return adAuthorizationMapper.deleteByPrimaryKey(authorizationId);
    }

    @Override
    public int insert(AdAuthorization record) {
        adAuthorizationMapper.insert(record);
        return record.getAuthorizationId();
    }

    @Override
    public int insertSelective(AdAuthorization record) {
        adAuthorizationMapper.insertSelective(record);
        return record.getAuthorizationId();
    }

    @Override
    public AdAuthorization selectByPrimaryKey(Integer authorizationId) {
        return adAuthorizationMapper.selectByPrimaryKey(authorizationId);
    }

    @Override
    public int updateByPrimaryKeySelective(AdAuthorization record) {
        return adAuthorizationMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(AdAuthorization record) {
        return adAuthorizationMapper.updateByPrimaryKey(record);
    }


    @Override
    public List<AdAuthorization> queryRoleResources(Integer roleId, Integer resourceType) {
        return adAuthorizationMapper.queryRoleResources(roleId, resourceType);
    }

    @Override
    public boolean checkUserHasResources(Integer userId, Integer resourceId, Integer resourceType) {
        return adAuthorizationMapper.checkUserHasResources(userId, resourceId, resourceType) > 0;
    }

    @Override
    public int deleteByRoleIdResourceType(Integer roleId, Integer resourceType) {
        return adAuthorizationMapper.deleteByRoleIdResourceType(roleId, resourceType);
    }


}
